Developer Documentation
PATHJava Developer Documentation > Mac OS Runtime for Java > JManager > Programming With JManager


Application-Defined Functions

This section describes the format of JManager callback functions you must implement in your application.


MyStandardOutput

Sends text to output. This is how you would define your output function if you were to name it MyStandardOutput:

void MyStandardOutput (
                     JMSessionRef session,
                     const char* message,
                     UInt32 messageLen);
session
The session sending the text.
message
The text to display.
messageLen
The length of the text.

DISCUSSION

When invoking the Java runtime environment using JMOpenSession , you must designate a callback function to display any console output received from the session.


MyStandardError

Directs error output. This is how you would define your error function if you were to name it MyStandardError:

void MyStandardError (
                     JMSessionRef session,
                     const char* message,
                     UInt32 messageLen);
session
The session sending the error text.
message
The error message to display.
messageLen
The length of the text.

DISCUSSION

When invoking the Java runtime environment using JMOpenSession , you must designate a callback function to direct any error output received from the session.The MyStandardError function has the same form as the MyStandardOutput callback function.

SEE ALSO

The MyStandardOutput function MyStandardOutput.


MyStandardIn

Reads text input. This is how you would define your input function if you were to name it MyStandardIn:

SInt32 MyStandardIn (JMSessionRef session,
                                         char* buffer,
                                         SInt32 maxBufferLength);
session
The session to receive the text input.
buffer
The buffer to hold the input.
maxBufferLength
The maximum length allowed by the buffer.
function result
The number of characters actually read (up to maxBufferLength ) or -1 if an error occurred.

DISCUSSION

When invoking the Java runtime environment using JMOpenSession , you must designate a callback function to direct any console input to the session.


MyExit

Handles calls to java.lang.System.exit . This is how you would define your input function if you were to name it MyExit:

Boolean MyExit (JMSessionRef session,
                     int value);
session
The session to end.
value
The status value to pass to System.exit .
function result
A Boolean value. If true, then the current thread is killed. If false, a QUIT Apple event is sent to the current process.

DISCUSSION

When invoking the Java runtime environment using JMOpenSession , you must designate a callback function (called MyExit here) to handle requests to quit. When a Java applet or application calls java.lang.System.exit , the session calls MyExit . Note that instead of passing false back to the session, you can simply dispose of the session and exit from within the MyExit function.


MyAuthenticate

Handles an authentication request for a URL. This is how you would define your authentication function if you were to name it MyAuthenticate:

Boolean MyAuthenticate (
                     JMSessionRef session,
                     const char* url,
                     const char* realm,
                     char userName[255],
                     char password[255]);
session
The session to receive the text input.
url
The URL making the authentication request.
realm
The realm associated with the URL.
userName
The name entered by the user.
password
The password entered by the user.
function result
A Boolean value. You should return false if the user selects to cancel the authentication, true otherwise.

DISCUSSION

When invoking the Java runtime environment using JMOpenSession , you can designate a callback function to handle any authentication requests from a URL. This callback should prompt the user for a name and password, and pass them back to the session. If you do not indicate an authentication callback, the Java session will prompt the user with its own authentication dialog box.


MyLowMem

Handles a low-memory condition. This is how you would define your low-memory function if you were to name it MyLowMem:

void MyLowMem (JMSessionRef session);
session
The session indicating the low-memory condition.

DISCUSSION

When invoking the Java runtime environment using JMOpenSession , you can designate a callback function to be called if the Java session runs low on memory. This callback typically notifies the user of the low-memory condition and suggests possible actions to take.


MyRequestFrame

Creates a new frame. This is how you would define your frame request function if you were to name it MyRequestFrame:

OSStatus MyRequestFrame (
                     JMAWTContextRef context,
                     JMFrameRef newFrame,
                     JMFrameKind kind,
                     const Rect* initialBounds,
                     Boolean resizeable,
                     JMFrameCallbacks* callbacks);
context
The AWT context making the frame request.
newFrame
A pointer to the new frame. on return, this parameter is the new frame.
kind
The type of frame desired. See Frame Types for a list of possible values for this field.
initialBounds
The initial dimensions of the frame.
resizeable
A Boolean value. If false, this frame is not resizeable; if true, you can resize the frame.
callbacks
A pointer to the frame callbacks data structure. on return, this parameter should specify the frame's callback functions. The AWT can then use these callbacks when it needs to modify a frame. See Frame Callbacks Structure for more information about this data structure.
function result
A result code. The function should return a standard result code.

DISCUSSION

When instantiating an AWT context, you must designate a callback function to handle requests for new frames.


MyReleaseFrame

Releases the frame. This is how you would define your frame release function if you were to name it MyReleaseFrame:

OSStatus MyReleaseFrame (
                     JMAWTContextRef context,
                     JMFrameRef oldFrame);
context
The AWT context containing the frame.
oldFrame
The frame to be released.
function result
A result code. The function should return a standard result code.

DISCUSSION

When instantiating an AWT context, you must designate a callback function to release existing frames.


MyUniqueMenuID

Allocates a new menu ID. This is how you would define your menu ID allocation function if you were to name it MyUniqueMenuID:

typedef SInt16 MyUniqueMenuID (
                     JMAWTContextRef context,
                     Boolean isSubmenu);
context
The AWT context containing the frame.
isSubMenu
A Boolean value. If false, the menu to add is a standard menu. If true, the menu is a submenu. The menu ID value of a submenu must be in the range 1 to 255.
function result
If successful, the function should return the ID of the new menu. Otherwise the function returns 0.

DISCUSSION

When instantiating an AWT context, you must designate a callback function to create new menu IDs if necessary.


MyExceptionOccurred

Indicates that an exception occurred. This is how you would define your exception notification function if you were to name it MyExceptionOccurred:

void MyExceptionOccurred (
                     JMAWTContextRef context,
                     const JMTextRef exceptionName,
                     const JMTextRef exceptionMsg,
                     const JMTextRef stackTrace);
context
The AWT context in which the exception occurred.
exceptionName
A text object containing the name of the exception.
exceptionMsg
A text object containing the exception message to display. This value is not guaranteed to be present and may be null .
stackTrace
A text object containing information about the call chain where the exception occurred. This value is not guaranteed to be present and may be null .

DISCUSSION

When instantiating an AWT context, you must designate a callback function to notify that an exception has occurred. You cannot use this function to recover from the exception; this function indicates only that an exception has occurred.


MyResizeRequest

Handles a request to change the size of a frame. This is how you would define your frame resize function if you were to name it MyResizeRequest:

Boolean MyResizeRequest (
                     JMFrameRef frame,
                     Rect* newBounds);
frame
The frame to be resized.
newBounds
A pointer to the new desired dimensions of the frame.
function result
True if the frame can be resized to the requested dimensions.

DISCUSSION

When creating a frame, you must designate a callback function to resize the frame if necessary. The function can refuse the resize request or adjust the frame size to something other than the requested dimensions. If your function sets a new frame size, you can modify the value of the newBounds parameter to reflect the new dimensions.


MyInvalRect

Handles a frame invalidation request. This is how you would define your invalidation request function if you were to name it MyInvalRect:

void MyInvalRect    (JMFrameRef frame,
                     const Rect* dimens);
frame
The frame that contains the area to be invalidated.
dimens
A pointer to the dimensions of the frame.

DISCUSSION

When creating a frame you must designate a callback function to invalidate a portion of the frame if necessary (in a manner similar to the MacOS Toolbox function call InvalRect ). The invalid portion can be updated later using the JMFrameUpdate function.

SEE ALSO

The JMFrameUpdate function JMFrameUpdate.


MyShowHide

Shows or hides a window associated with a frame. This is how you would define your show/hide function if you were to name it MyShowHide:

void MyShowHide     (JMFrameRef frame,
                     Boolean showFrameRequested);
frame
The frame to be shown or hidden.
showFrameRequested
A Boolean value. If true, the window should be displayed. If false, the window should be hidden.

DISCUSSION

When creating a frame, you must designate a callback function to show or hide the window associated with it.


MySetTitle

Sets the title bar text for the frame. This is how you would define your title bar function if you were to name it MySetTitle:

void MySetTitle     (JMFrameRef frame,
                     const JMTextRef title);
frame
The frame that contains the title bar to be set or changed.
title
The title to display, as a text object.

DISCUSSION

When creating a frame you must designate a callback function to set or modify the title bar associated with it.


MyCheckUpdate

Checks to see if a frame update is necessary. This is how you would define your update check function if you were to name it MyCheckUpdate:

void MyCheckUpdate  (JMFrameRef frame);
frame
The frame to be checked.

DISCUSSION

When creating a frame you must designate a callback function to check if a frame update is needed. This function may be called to enable updates for interactions such as live scrolling or other mouse-tracking maneuvers. If the function determines that an update is necessary (that is, the update region is not empty), it should call JMFrameUpdate in addition to the usual Window Manager calls ( BeginUpdate , EndUpdate , and so on) to perform the update.

SEE ALSO

The JMFrameUpdate function JMFrameUpdate.


MyFrameReorder

Reorders the frame. This is how you would define your frame reorder function if you were to name it MyFrameReorder:

void MyFrameReorder (
                     JMFrameRef frame,
                     enum ReorderRequest theRequest);
frame
The frame to be reordered.
theRequest
The desired reordering. See Frame Ordering Indicators for a list of possible values.

DISCUSSION

When creating a frame you must designate a callback function to reorder the frame if necessary (for example, to bring it to the front or send it to the back). Note that you should not reorder frames such that a modal frame appears on top of a nonmodal one.


MySetResizeable

Designates whether a frame is resizeable. This is how you would define your set resizeable function if you were to name it MySetResizeable:

void MySetResizeable (
                     JMFrameRef frame,
                     Boolean resizeable);
frame
The frame to designate as resizeable or not.
resizeable
If true, the frame should be designated as resizeable.

DISCUSSION

When creating a frame you must designate a callback function to set the frame as resizeable or not. The callback can allow or disallow the use of the grow control depending on the value of resizeable .


MyFetchCompleted

Executes after an attempt to retrieve HTML data using the JMNewAppletLocator function. This is how you would define your output function if you were to name it MyFetchCompleted:

void MyFetchCompleted (
                     JMAppletLocatorRef ref,
                     JMLocatorErrors status);
ref
The newly created applet locator.
status
The status of the HTML data retrieval. See Applet Locator Status Values for a listing of values that JMNewAppletLocator may pass in this parameter.

DISCUSSION

When calling JMNewAppletLocator , you must designate this function in the applet locator callbacks structure. The actions taken by the completion function depend on the status value it receives from JMNewAppletLocator . For example, if the HTML text is retrieved successfully, the function can then proceed to instantiate an applet associated with the HTML page.

SEE ALSO

The JMNewAppletLocator function JMNewAppletLocator.


MyShowDocument

Displays the contents of a URL passed back by an instantiated applet. This is how you would define your output function if you were to name it MyShowDocument:

void MyShowDocument (JMAppletViewerRef viewer,
                     const JMTextRef urlString,
                     const JMTextRef windowName);
viewer
The current applet.
urlString
A text object containing the URL passed by the applet.
windowName
A text object describing the type of window to display the URL contents.

DISCUSSION

When calling JMNewAppletViewer , you must designate this function in the applet callbacks structure.

The session passes one of the strings in Table 2-1 in the WindowName parameter, and your application should display the URL contents accordingly.

Table 2-1 Window strings passed to MyShowDocument

String

Action

_self Show contents in the current frame
_parent Show contents in the parent frame
_top Show contents in the top-most (that is, front-most) frame
_blank Show contents in a new unnamed window
frameName Show contents in a new window named frameName

SEE ALSO

The JMNewAppletViewer function JMNewAppletViewer.


MySetStatusMsg

Handles any status messages passed back by an instantiated applet. This is how you would define your output function if you were to name it MySetStatusMsg:

void MySetStatusMsg (JMAppletViewerRef viewer,
                     const char* statusMsg);
viewer
The current applet.
statusMsg
The status text passed by the applet.

DISCUSSION

When calling JMNewAppletViewer , you must designate this function in the applet callbacks data structure. The function can display the status message or ignore it, whichever is appropriate.

SEE ALSO

The JMNewAppletViewer function.


© 1998 Apple Computer, Inc. — (Last Updated 3 Dec 98)